package org.summer.lawyer.handle;

import jakarta.annotation.Resource;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.summer.lawyer.domain.vo.paytransfer.PayTransferVo;
import org.summer.lawyer.event.PayTransferSuccessEvent;
import org.summer.lawyer.service.IBrokerageUserService;
import org.summer.lawyer.service.IUserWalletLogService;

/**
 *
 */
@Getter
@Slf4j
@Component
public class PayTransferSuccessHandle implements ApplicationListener<PayTransferSuccessEvent> {

    private PayTransferVo payTransferVo;

    @Resource
    private IBrokerageUserService brokerageUserService;

    @Resource
    private IUserWalletLogService userWalletLogService;

    /**
     * 转账成功处理
     */
    @Async
    @Override
    public void onApplicationEvent(PayTransferSuccessEvent event) {
        this.payTransferVo = event.getPayTransferVo();
        //更新记录
        brokerageUserService.updateBrokerageWithdraw(payTransferVo);

    }

}
